﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.orders.Valentines2011 {
    import Classes.orders.*;

    public class ValentineOrder extends AbstractOrder {

        private static const CARDS:String = "cards";
        private static const CARD_SEEN:String = "card_seen";
        private static const CARD_DATA:String = "card_data";
        private static const CARD_TOTAL:String = "card_total";
        private static const CARD_ID:String = "id";

        private var m_cards:Array;

        public function ValentineOrder(_arg1:String, _arg2:String){
            super(_arg1, _arg2, OrderType.VALENTINE_2011, null, null);
            this.m_cards = new Array();
        }
        override public function setParams(_arg1:Object):void{
            var _local2:Object;
            m_params[ValentineOrder.CARDS] = _arg1[ValentineOrder.CARDS];
            m_params[ValentineOrder.CARD_TOTAL] = _arg1[ValentineOrder.CARD_TOTAL];
            for each (_local2 in m_params[ValentineOrder.CARDS]) {
                this.m_cards.push(new ValentineCard(_local2[ValentineOrder.CARD_DATA], Boolean(_local2[ValentineOrder.CARD_SEEN]), getSenderID(), this, String(_local2[ValentineOrder.CARD_ID])));
            };
        }
        public function getNewCards():Array{
            var _local2:ValentineCard;
            var _local1:Array = new Array();
            for each (_local2 in this.m_cards) {
                if (_local2.isNew()){
                    _local1.push(_local2);
                };
            };
            return (_local1);
        }
        public function getAllCards():Array{
            return (this.m_cards);
        }
        public function getCardCount():int{
            return (m_params[ValentineOrder.CARD_TOTAL]);
        }
        public function hasNewCards():Boolean{
            return ((this.getNewCards().length > 0));
        }
        public function setCardAsSeen(_arg1:String):void{
            var _local2:ValentineCard;
            for each (_local2 in this.m_cards) {
                if (_local2.id == _arg1){
                    _local2.setSeen();
                    return;
                };
            };
        }
        public function deleteCard(_arg1:String):Boolean{
            var _local2:int;
            while (_local2 < this.m_cards.length) {
                if (this.m_cards[_local2].id == _arg1){
                    this.m_cards.splice(_local2, 1);
                    m_params[CARD_TOTAL] = (m_params[CARD_TOTAL] - 1);
                    return (true);
                };
                _local2++;
            };
            return (false);
        }

    }
}//package Classes.orders.Valentines2011 
